package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 床控制器
 *
 * @author 16203
 * @date 2024/08/05
 */
@RestController
@RequestMapping("/bed")
@Api(tags = "床位管理")
@Slf4j
public class BedController {
    @Autowired
    BedService bedService;


    /**
     * 创造
     *
     * @param bedDto 床dto
     * @return {@code ResponseResult<Void> }
     * @author 16203
     */
    @ApiOperation("新增床位")
    @PostMapping("/create")
    public ResponseResult<Void> create(@RequestBody BedDto bedDto) {
        log.info("新增床位:{}", bedDto);
        bedService.create(bedDto);
        return ResponseResult.success();
    }


    @ApiOperation("根据ID查询床位")
    @GetMapping("/read/{id}")
    public ResponseResult<BedVo> read(@PathVariable Long id) {
        log.info("根据ID查询床位:{}", id);
        return ResponseResult.success(bedService.read(id));
    }

    @ApiOperation("更新床位")
    @PutMapping("/update")
    public ResponseResult<Void> update(@RequestBody BedDto bedDto) {
        log.info("更新床位:{}", bedDto);
        bedService.update(bedDto);
        return ResponseResult.success();
    }

    @ApiOperation("删除床位")
    @DeleteMapping("/delete/{id}")
    public ResponseResult<Void> delete(@PathVariable Long id) {
        log.info("删除床位:{}", id);
        bedService.delete(id);
        return ResponseResult.success();
    }
}
